package com.kingyun.gpsinspection.purificationservice.services.iam.innerservice.scyx.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cqhilink.api.common.utils.UniqueUtil;
import com.kingyun.gpsinspection.purificationservice.common.utils.BootstrapUtil;
import com.kingyun.gpsinspection.purificationservice.common.enums.DeviceSumTypeEnum;
import com.kingyun.gpsinspection.purificationservice.dao.mapper.iam.accessory.EntityPropertyVoMapper;
import com.kingyun.gpsinspection.purificationservice.dao.mapper.iam.accessory.EntityTypePropertyVoMapper;
import com.kingyun.gpsinspection.purificationservice.dao.mapper.iam.accessory.EntityVoMapper;
import com.kingyun.gpsinspection.purificationservice.dao.mapper.iam.scyx.DeviceSumDevitemMapper;
import com.kingyun.gpsinspection.purificationservice.dao.mapper.iam.scyx.DeviceSumDevlistMapper;
import com.kingyun.gpsinspection.purificationservice.dao.mapper.iam.scyx.DeviceSumInfoMapper;
import com.kingyun.gpsinspection.purificationservice.facade.model.iam.accessory.EntityPropertyVo;
import com.kingyun.gpsinspection.purificationservice.facade.model.iam.accessory.EntityTypePropertyVo;
import com.kingyun.gpsinspection.purificationservice.facade.model.iam.accessory.EntityVo;
import com.kingyun.gpsinspection.purificationservice.facade.model.iam.scyx.*;
import com.kingyun.gpsinspection.purificationservice.facade.service.iam.scyx.DeviceSumInfoService;
import com.kingyun.gpsinspection.purificationservice.facade.service.iam.scyx.DeviceSumTempInfoService;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.HSSFColor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

/**
 * Created by yangsy on 2016/12/7.
 */
public class DeviceSumInfoServiceImpl implements DeviceSumInfoService {
    private static Logger logger = LoggerFactory.getLogger(DeviceSumInfoServiceImpl.class);
    @Autowired
    private DeviceSumInfoMapper deviceSumInfoMapper;
    @Autowired
    private DeviceSumDevlistMapper deviceSumDevlistMapper;
    @Autowired
    private  DeviceSumDevitemMapper deviceSumDevitemMapper;
    @Autowired
    private DeviceSumTempInfoService deviceSumTempInfoService;
    @Autowired
    private EntityVoMapper entityVoMapper;
    @Autowired
    private EntityTypePropertyVoMapper entityTypePropertyVoMapper;
    @Autowired
    private EntityPropertyVoMapper entityPropertyVoMapper;
    @Override
    public DeviceSumInfo selectByPrimaryKey(String deviceSumId) {
        return deviceSumInfoMapper.selectByPrimaryKey(deviceSumId);
    }


    @Override
    public JSONObject list(DeviceSumInfo deviceSumInfo) {
        JSONObject jsonObject = new JSONObject();
        deviceSumInfo.setLimit(deviceSumInfo.getLimit() == null ? 10 : deviceSumInfo.getLimit());
        deviceSumInfo.setOffset(deviceSumInfo.getOffset() == null ? 0 : deviceSumInfo.getOffset());
        deviceSumInfo.setFilterMap(BootstrapUtil.filterStringToMap(deviceSumInfo.getFilter()));
        jsonObject.put("total", deviceSumInfoMapper.queryCount(deviceSumInfo));
        jsonObject.put("rows", JSON.toJSON(deviceSumInfoMapper.queryList(deviceSumInfo)));
        return jsonObject;
    }


    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public int insertSelective(String deviceSumTempId) {
        int resultCount = 0;
        if (StringUtils.isEmpty(deviceSumTempId)) {
            return resultCount;
        }
        //  根据 台账模板Id  查询台账模板相关信息
        DeviceSumTempInfo deviceSumTempInfo = deviceSumTempInfoService.selectSubTypeInfo(deviceSumTempId);
        //  设置台账实例化信息相关表的数据
        //  设置设备台账信息
        DeviceSumInfo deviceSumInfo = new DeviceSumInfo();
        String deviceSumId = UniqueUtil.uuid();
        //  主键
        deviceSumInfo.setDeviceSumId(deviceSumId);
        //  台账名称
        deviceSumInfo.setDeviceSumName(pottingDeviceSumName(deviceSumTempInfo));
        //  组织
        deviceSumInfo.setOrgId(deviceSumTempInfo.getOrgId());
        //  台账类型
        deviceSumInfo.setDeviceSumType(deviceSumTempInfo.getDeviceSumType());
        //  创建人
        deviceSumInfo.setCreatorId(deviceSumTempInfo.getCreatorId());
        //  创建时间
        deviceSumInfo.setCreateDate(new Date());
        //  修改人
        deviceSumInfo.setModifierId(deviceSumTempInfo.getModifierId());
        //  修改时间
        deviceSumInfo.setModifyDate(deviceSumTempInfo.getModifyDate());
        //  备注
        deviceSumInfo.setDescription(deviceSumTempInfo.getDescription());
        //  台账日期
        deviceSumInfo.setDeviceSumDate(new Date());
        //  更新 台账设备列表信息
        //  根据设备台账模板Id, 获取子类型数据
        //  如果台账模板不为空，及其台账模板子类型不为空
        if(deviceSumTempInfo != null && deviceSumTempInfo.getSubTypeInfo() != null){
            //  insert 操作  设备台账表
            resultCount += deviceSumInfoMapper.insertSelective(deviceSumInfo);
            //  当前台账模板子类型数据
            List<DeviceSumTempInfoVo> list = deviceSumTempInfo.getSubTypeInfo();
            //  遍历当前台账模板子类型数据
            for(DeviceSumTempInfoVo vo : list){
                //  对设备列表数据进行封装
                List<DeviceSumDevlist> deviceSumDevlistList = new ArrayList<>();
                deviceSumDevlistList = pottingDeviceSumDevlist(deviceSumId,deviceSumTempInfo.getOrgId(),vo);
                for (DeviceSumDevlist deviceSumDevlist : deviceSumDevlistList) {
                    //  inset 操作 设备台账列表
                    resultCount += deviceSumDevlistMapper.insertSelective(deviceSumDevlist);
                    //  操作设备采集项数据
                    List<DeviceSumDevitem> deviceSumDevitemList = pottingDeviceSumDevitem(vo, deviceSumDevlist);
                    if (deviceSumDevitemList == null || deviceSumDevitemList.size() < 0) {
                        continue;
                    }
                    for (DeviceSumDevitem deviceSumDevitem : deviceSumDevitemList) {
                        //  insert 操作 设备采集项数据
                        resultCount += deviceSumDevitemMapper.insertSelective(deviceSumDevitem);
                    }
                }
            }
        }
        return resultCount;
    }

    @Override
    public List<DeviceSumInfoVo> deviceSumSubTypeInfo(String deviceSumId) {
        return deviceSumInfoMapper.deviceSumSubTypeInfo(deviceSumId);
    }

    @Override
    public void carateWb(HSSFWorkbook wb, String deviceSumId) {
        //一个设备台账 可以对应多个子类型
        //  获取台账子类型信息
        List<DeviceSumInfoVo> list = deviceSumInfoMapper.deviceSumSubTypeInfo(deviceSumId);
        int len = list.size();
        for (int i = 0; i < len; i++) {
            //  单个子类型信息
            DeviceSumInfoVo deviceSumInfoVo = list.get(i);
            HSSFSheet sheet = wb.createSheet((i+1) + "." +deviceSumInfoVo.getSubtypeName());

            // 第三步，在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short
            HSSFRow row = sheet.createRow((int) 0);

            // 第四步，创建单元格，并设置值表头 设置表头居中
            HSSFCellStyle style = wb.createCellStyle();
            style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式

            HSSFFont font=wb.createFont();
            font.setColor(HSSFColor.BLACK.index);//HSSFColor.VIOLET.index //字体颜色
            font.setFontHeightInPoints((short)12);
            //font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);         //字体增粗
            // 字体高度
            //font.setFontHeightInPoints((short) 20);
            font.setColor(HSSFFont.COLOR_NORMAL);// 字体颜色
            // 字体
            font.setFontName("黑体");
            //把字体应用到当前的样式
            style.setFont(font);
            // 表头数据
            List<EntityTypePropertyVo> entityTypePropertyVoList = this.getEntityTypePropertys(deviceSumInfoVo);
            if (entityTypePropertyVoList == null || entityTypePropertyVoList.size() < 0) {
                return;
            }
            //  第一列默认为序号
            EntityTypePropertyVo entityTypePropertyVo = new EntityTypePropertyVo();
            entityTypePropertyVo.setPropertyName("序号");
            entityTypePropertyVoList.add(0,entityTypePropertyVo);
            int entityTypePropertyVoListLen = entityTypePropertyVoList.size();
            //  第一行为表头内容
            for (int j = 0; j < entityTypePropertyVoListLen; j++) {
                EntityTypePropertyVo vo = entityTypePropertyVoList.get(j);
                HSSFCell cell = row.createCell(j);
                cell.setCellValue(vo.getPropertyName());
                sheet.setColumnWidth(j, 520 * 32);
                cell.setCellStyle(style);//  设置表头样式
                sheet.autoSizeColumn(j, true);
            }
            //  查询生产实体信息数据
            List<DeviceSumDevlist> deviceSumDevlistList = deviceSumDevlistMapper.queryListNotpading(deviceSumInfoVo);
            if(deviceSumDevlistList == null || deviceSumDevlistList.size() < 0){
                return ;
            }
            int deviceSumDevlistListLen = deviceSumDevlistList.size();
            //  生产实体特性值
            Map<String, Object> propertyValue = getETPropertyValue(deviceSumInfoVo);
            for (int j = 0; j < deviceSumDevlistListLen; j++) {
                DeviceSumDevlist deviceSumDevlist = deviceSumDevlistList.get(j);
                row = sheet.createRow((int) j + 1);
                for (int k = 0; k < entityTypePropertyVoListLen; k++) {
                    EntityTypePropertyVo vo = entityTypePropertyVoList.get(k);
                    //  特性值
                    String _propertyValue = "";
                    if (k == 0) {
                        //  序号
                        _propertyValue = String.valueOf(j+1);
                    } else if(k == 1){
                        //  设备名称
                        _propertyValue = deviceSumDevlist.getDevlistName();
                    }else {
                        //  主键 +  设备特性Id  获取单个值
                        String key = deviceSumDevlist.getId() + vo.getDevicePropertyId();
                        _propertyValue = (String) propertyValue.get(key);
                    }
                    row.createCell(k).setCellValue(_propertyValue);
                }

            }
        }
    }

    /**
     * 封装设备台账列表数据
     * @param deviceSumId 设备台账Id
     * @param orgId 对应组织
     * @param vo 设备台账模板子类型信息
     * @return
     */
    protected List<DeviceSumDevlist> pottingDeviceSumDevlist(String deviceSumId, String orgId,DeviceSumTempInfoVo vo) {
        EntityVo entityVo = new EntityVo();
        //  设置生产实体类型Id
        entityVo.setEntityTypeId(vo.getEntityTypeId());
        //  设置对应组织
        entityVo.setParentOrgId(orgId);
        List<EntityVo> entityVoList = entityVoMapper.queryListNotPaging(entityVo);

        List<DeviceSumDevlist> deviceSumDevlistList = new ArrayList<>();
        DeviceSumDevlist deviceSumDevlist = new DeviceSumDevlist();

        if(entityVoList !=null &&  entityVoList.size() > 0){
            int len = entityVoList.size();
            for(int i=0;i<len;i++){
                deviceSumDevlist = new DeviceSumDevlist();
                //  主键
                deviceSumDevlist.setId(UniqueUtil.uuid());
                //  设备台账id
                deviceSumDevlist.setDeviceSumId(deviceSumId);
                //  设备项id（生产实体id
                deviceSumDevlist.setDevlistId(entityVoList.get(i).getEntityId());
                //  企业自编码
                deviceSumDevlist.setDeviceCode("");
                //  子类型Id
                deviceSumDevlist.setSubtypeId(vo.getDeviceSumSubtypeId());
                //  子类型名称
                deviceSumDevlist.setSubtypeName(vo.getSubtypeName());
                deviceSumDevlistList.add(deviceSumDevlist);
            }
        }else{
            //  主键
            deviceSumDevlist.setId(UniqueUtil.uuid());
            //  设备台账id
            deviceSumDevlist.setDeviceSumId(deviceSumId);
            //  设备项id（生产实体id
            deviceSumDevlist.setDevlistId("");
            //  企业自编码
            deviceSumDevlist.setDeviceCode("");
            //  子类型Id
            deviceSumDevlist.setSubtypeId(vo.getDeviceSumSubtypeId());
            //  子类型名称
            deviceSumDevlist.setSubtypeName(vo.getSubtypeName());
            deviceSumDevlistList.add(deviceSumDevlist);
        }
        return deviceSumDevlistList;
    }

    /**
     * 设置 台账采集项信息
     * @param deviceSumTempInfoVo
     * @param deviceSumDevlist
     * @return
     */
    private List<DeviceSumDevitem> pottingDeviceSumDevitem(DeviceSumTempInfoVo deviceSumTempInfoVo,DeviceSumDevlist deviceSumDevlist){
        //  台账模板列表Id
        String devlistTempId = deviceSumTempInfoVo.getDevlistTempId();
        //  获取台账模板配置的生产实体类型特性
        List<EntityTypePropertyVo> entityTypePropertyVoList = new ArrayList<>();
        entityTypePropertyVoList = entityTypePropertyVoMapper.queryList2(devlistTempId);
        if(entityTypePropertyVoList == null || entityTypePropertyVoList.size() < 0){
            return null;
        }
        Map<String,Object> retMap =  this.getEntityPropertyValue(deviceSumTempInfoVo);
        int len = entityTypePropertyVoList.size();
        List<DeviceSumDevitem> deviceSumDevitemList = new ArrayList<>();
        for(int i=0;i<len;i++){
            EntityTypePropertyVo vo = entityTypePropertyVoList.get(i);
            //  设备采集项
            DeviceSumDevitem deviceSumDevitem = new DeviceSumDevitem();
            //  主键
            deviceSumDevitem.setDeviceSumDevitemId(UniqueUtil.uuid());
            //  数据id
            deviceSumDevitem.setDeviceSumDevlistId(deviceSumDevlist.getId());
            //  设备项id( 生产实体id
            deviceSumDevitem.setDevlistId(deviceSumDevlist.getDevlistId());
            //  设备特性Id
            deviceSumDevitem.setDevPropertyId(vo.getDevicePropertyId());
            //  序号
            deviceSumDevitem.setSortNum(i+1);
            //  根据数据来源 获取特性值
            String dataSoursetype = vo.getDatasoursetype();
            String propertyValue  = "";
            if (dataSoursetype == null || "".equals(dataSoursetype)) {
                //  直接 从实体特性里面获取数据
                //  特性值类型
                deviceSumDevitem.setPropertyType(Short.valueOf(vo.getPropertyType()));
                //  特性值单位
                deviceSumDevitem.setPropertyUnit(vo.getPropertyType());
                String key = deviceSumDevlist.getDevlistId() + vo.getDevicePropertyId();
                propertyValue = (String ) retMap.get(key);
            } else {
                //  从基本信息表里面获取数据
                EntityVo entityVo = entityVoMapper.selectByPrimaryKey(deviceSumDevlist.getDevlistId() == null? "" : deviceSumDevlist.getDevlistId());
                if(entityVo != null){
                    propertyValue = ReflectUtil.reflectGetValue(entityVo, dataSoursetype, vo.getColumnCode());
                }
            }
            deviceSumDevitem.setPropertyValue(propertyValue);
            deviceSumDevitemList.add(deviceSumDevitem);
        }
        return deviceSumDevitemList;
    }

    /**
     * 封装设备台账名称
     * 动态生成设备台账名称
     * 规则 ：对应组织 +  模板名称+日期
     * @param deviceSumTempInfo
     * @return
     */
    private String pottingDeviceSumName(DeviceSumTempInfo deviceSumTempInfo){
        String deviceSumName = "";
        if(deviceSumTempInfo == null){
            return deviceSumName;
        }
        deviceSumName += deviceSumTempInfo.getOrgName() + "-";
        deviceSumName += deviceSumTempInfo.getDeviceSumTempName() + "-";
        Calendar now = Calendar.getInstance();
        int year = now.get(Calendar.YEAR);
        int month = now.get(Calendar.MONTH) + 1;
        if(deviceSumTempInfo.getDeviceSumType() == Short.parseShort(
                DeviceSumTypeEnum.DEVICE_SUM_TYPE_ENUM_2.getCode().toString())){
            //  月台账
            deviceSumName += year + "年" + month + "月";
        }
        if(deviceSumTempInfo.getDeviceSumType() == Short.parseShort(
                DeviceSumTypeEnum.DEVICE_SUM_TYPE_ENUM_3.getCode().toString())){
            deviceSumName += year + "年" ;
        }
        return deviceSumName;
    }


    @Override
    public Object getDeviceTitle(DeviceSumInfoVo deviceSumInfoVo) {
        List<EntityTypePropertyVo> list = this.getEntityTypePropertys(deviceSumInfoVo);
        if (list == null || list.size() < 0) return null;
        List<Map<String, String>> mapList = new ArrayList<>();
        for (EntityTypePropertyVo entityTypePropertyVo : list) {
            Map<String, String> map = new HashMap<>();
            map.put("title", entityTypePropertyVo.getPropertyName());
            map.put("field", entityTypePropertyVo.getDevicePropertyId());
            mapList.add(map);
        }
        return JSON.toJSON(mapList);
    }

    @Override
    public JSONObject getDeviceContent(DeviceSumInfoVo deviceSumInfoVo) {
        //  查询当前子类型台账内容信息
        JSONObject jsonObject = new JSONObject();
        deviceSumInfoVo.setLimit(deviceSumInfoVo.getLimit() == null ? 10 : deviceSumInfoVo.getLimit());
        deviceSumInfoVo.setOffset(deviceSumInfoVo.getOffset() == null ? 0 : deviceSumInfoVo.getOffset());
        //  查询当前子类型下面的生产实体数据
        List<DeviceSumDevlist> entityList = deviceSumDevlistMapper.queryList(deviceSumInfoVo);//
        if (entityList == null || entityList.size() < 0) {
            return null;
        }
        //  生产实体类型特性数据
        List<EntityTypePropertyVo> list = this.getEntityTypePropertys(deviceSumInfoVo);
        if (list == null || list.size() < 0) {
            return null;
        }
        //  取设备特性具体值
        Map<String, Object> resultMap = getETPropertyValue(deviceSumInfoVo);
        //  封装数据
        List<Map<String, String>> addProList = new ArrayList<>();
        //  遍历生产实体数据
        for (DeviceSumDevlist deviceSumDevlist : entityList) {
            Map<String, String> retMap = new HashMap<>();
            //  遍历生产实体类型特性数据
            for (EntityTypePropertyVo vo : list) {
                //  特性值
                String propertyValue = "";
                //  默认第一列为固定类型，设备名称
                if (vo.getDevicePropertyId().equals("entityId")) {
                    propertyValue = deviceSumDevlist.getDevlistName();
                } else {
                    //  设备项Id +  生产实体类型特性Id
                    String key = deviceSumDevlist.getId() + vo.getDevicePropertyId();
                    propertyValue = (String) resultMap.get(key);
                }
                retMap.put(vo.getDevicePropertyId(), propertyValue);
            }
            addProList.add(retMap);
        }
        jsonObject.put("total", deviceSumDevlistMapper.queryCount(deviceSumInfoVo));
        jsonObject.put("rows", JSON.toJSON((addProList)));
        return jsonObject;
    }

    @Override
    public JSONObject getExcelData(String deviceSumId) {
        JSONObject jsonObject = new JSONObject();
        //一个设备台账 可以对应多个子类型
        //  获取台账子类型信息
        List<DeviceSumInfoVo> list = deviceSumInfoMapper.deviceSumSubTypeInfo(deviceSumId);
        int len = list.size();
        for (int i = 0; i < len; i++) {
            //  单个子类型信息
            DeviceSumInfoVo deviceSumInfoVo = list.get(i);
            Map<String,Object> map = new HashMap<>();
            map.put("sheetName","." +deviceSumInfoVo.getSubtypeName());
            // 表头数据
            List<EntityTypePropertyVo> entityTypePropertyVoList = this.getEntityTypePropertys(deviceSumInfoVo);
            if(entityTypePropertyVoList !=null && entityTypePropertyVoList.size()>0 ){
                //  第一列默认为序号
                EntityTypePropertyVo entityTypePropertyVo = new EntityTypePropertyVo();
                entityTypePropertyVo.setPropertyName("序号");
                entityTypePropertyVoList.add(0,entityTypePropertyVo);
            }
            map.put("titleName",entityTypePropertyVoList);
            //  查询生产实体信息数据
            List<DeviceSumDevlist> deviceSumDevlistList = deviceSumDevlistMapper.queryListNotpading(deviceSumInfoVo);
            map.put("coentent",deviceSumDevlistList);
            //  生产实体特性值
            Map<String, Object> propertyValue = getETPropertyValue(deviceSumInfoVo);
            map.put("propertyValue",propertyValue);
            jsonObject.put("item_"+i,map);
        }
        return jsonObject;
    }

    /**
     * 获取生产实体类型特性
     *
     * @param deviceSumInfoVo
     * @return
     */
    private List<EntityTypePropertyVo> getEntityTypePropertys(DeviceSumInfoVo deviceSumInfoVo) {
        if (deviceSumInfoVo == null) return null;
        //  封装当前子类型台账表头信息
        Map<String, String> map = new HashMap<>();
        map.put("subtypeId", deviceSumInfoVo.getSubtypeId());
        map.put("deviceSumId", deviceSumInfoVo.getDeviceSumId());
        List<EntityTypePropertyVo> list = entityTypePropertyVoMapper.queryList3(map);
        if (list == null || list.size() < 0) return null;
        EntityTypePropertyVo entityTypePropertyVo = new EntityTypePropertyVo();
        entityTypePropertyVo.setDevicePropertyId("entityId");
        entityTypePropertyVo.setPropertyName("设备名称");
        list.add(0, entityTypePropertyVo);
        return list;
    }

    /**
     * 根据设备列表Id  获取设备详细信息
     *
     * @param deviceSumInfoVo
     * @return
     */
    private List<DeviceSumDevitem> getDeviceSumDevitems(DeviceSumInfoVo deviceSumInfoVo) {
        if (deviceSumInfoVo == null) {
            return null;
        }
        List<DeviceSumDevitem> list = null;
        try {
            Map<String, String> map = new HashMap<>();
            map.put("deviceSumId", deviceSumInfoVo.getDeviceSumId());//设备台账Id
            map.put("subtypeId", deviceSumInfoVo.getSubtypeId());
            list = deviceSumDevitemMapper.queryList(map);
        } catch (Exception e) {
            logger.error("调用设备信息异常：" + e.getMessage());
        }
        return list;
    }

    /***
     * 封装数据
     * 获取单个生产实体某个实体特性值，封装数据
     * 键为 数据项id + 生产实体类型特性id
     *
     * @param deviceSumInfoVo
     * @return
     */
    private Map<String, Object> getETPropertyValue(DeviceSumInfoVo deviceSumInfoVo) {
        if (deviceSumInfoVo == null) {
            return null;
        }
        List<DeviceSumDevitem> list = this.getDeviceSumDevitems(deviceSumInfoVo);
        if (list == null || list.size() < 0) {
            return null;
        }
        //  封装数据 返回map  便于取值
        Map<String, Object> map = new HashMap<>();
        //  遍历设备信息  deviceSumDevitemId
        for (DeviceSumDevitem devitem : list) {
            //
            String key = devitem.getDeviceSumDevlistId() + devitem.getDevPropertyId();
            map.put(key, devitem.getPropertyValue());
        }
        return map;
    }

    /**
     * 获取生产实体特性值数据
     *
     * @param deviceSumTempInfoVo
     * @return
     */
    protected Map<String, Object> getEntityPropertyValue(DeviceSumTempInfoVo deviceSumTempInfoVo) {
        Map<String, Object> map = new HashMap<>();
        if (deviceSumTempInfoVo == null) {
            return map;
        }
        EntityPropertyVo entityPropertyVo = new EntityPropertyVo();
        entityPropertyVo.setEntityTypeId(deviceSumTempInfoVo.getEntityTypeId());
        List<EntityPropertyVo> list = entityPropertyVoMapper.queryList(entityPropertyVo);
        if (list == null || list.size() < 0) {
            return map;
        }
        //  循环遍历 生产实体 特性数据
        for (EntityPropertyVo e : list) {
            //  生产实体Id  + 生产实体特性id 作为key
            String key = e.getEntityId() + e.getEntpPropertyId();
            map.put(key, e.getPropertyValue());
        }
        return map;
    }
}
